from typing import Type

from pydantic import BaseModel

from utils.paths import CONFIG_PATH
from utils.utils import load_yaml


class HubstudioPath(BaseModel):
    envList: str
    envStart: str


class HubstudioConfig(BaseModel):
    baseUrl: str
    appID: str
    appSecret: str
    paths: HubstudioPath


class Config(BaseModel):
    hubstudio: HubstudioConfig
    defaultUrl: str

    @classmethod
    def load(cls) -> Type['Config']:
        config_dict = load_yaml(CONFIG_PATH)

        cls.hubstudio = HubstudioConfig(
            baseUrl=config_dict['HS_BASE_URL'],
            appID=config_dict['HS_APP_ID'],
            appSecret=config_dict['HS_APP_SECRET'],
            paths=HubstudioPath(
                envList=config_dict['HS_PATH']['ENV_LIST'],
                envStart=config_dict['HS_PATH']['ENV_START']
            )
        )
        cls.defaultUrl = config_dict['DEFAULT_URL']
        cls.mouseRecordShortcut = config_dict['MOUSE_RECORD_SHORTCUT']

        return cls


Config.load()

if __name__ == '__main__':
    config = Config.load()

    A = 1
